﻿using BuilderDemo;
using System.Runtime.InteropServices;

var director = new PlayerDirector();
Player? player;

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
    player = director.BuildPlayer(new WindowsPlayerBuilder());
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
    player = director.BuildPlayer(new LinuxPlayerBuilder());
else
    throw new Exception("Only Linux and Windows operating system are supported.");

Console.WriteLine("请指定播放文件的路径：");
var filePath = Console.ReadLine() ?? string.Empty;
player.PlayButton?.Play(filePath);

Console.WriteLine("正在播放音频，键入'stop'来停止播放或'exit'来退出此应用");
while (true)
{
    var command = Console.ReadLine();
    if (command == "stop")
        player.StopButton?.Stop(filePath);
    else if (command == "exit")
        break;
}

Console.ReadKey();